| Total Complexity | 2 |
| Total Lines | 21 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import { Inject, Injectable } from '@nestjs/common'; |
||
| 5 | |||
| 6 | @Injectable() |
||
| 7 | export class UserSerializer extends PassportSerializer { |
||
| 8 | constructor( |
||
| 9 | @Inject('IUserRepository') |
||
| 10 | private readonly userRepository: IUserRepository |
||
| 11 | ) { |
||
| 12 | super(); |
||
| 13 | } |
||
| 14 | |||
| 15 | serializeUser(user: AuthenticatedView, done: Function) { |
||
| 16 | done(null, user); |
||
| 17 | } |
||
| 18 | |||
| 19 | public async deserializeUser( |
||
| 20 | view: AuthenticatedView, |
||
| 21 | done: Function |
||
| 22 | ): Promise<void> { |
||
| 23 | const user = await this.userRepository.findOneById(view.id); |
||
| 24 | |||
| 25 | done(null, user); |
||
| 26 | } |
||
| 28 |